clear all
set more off

local path0="C:\Dropbox\GeneticsProject (1)\REStat\round_accepted_replication_files\"

*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cd "`path0'data_proprietory\CominMiesteri"
use "baseline_estimates", clear

gen countrycode=""
replace countrycode = "AFG" if countryname=="AFG"
replace countrycode = "ALB" if countryname=="ALB"
replace countrycode = "DZA" if countryname=="ALG"
replace countrycode = "ARG" if countryname=="ARG"
replace countrycode = "ARM" if countryname=="ARM"
replace countrycode = "AUS" if countryname=="AUL"
replace countrycode = "AUT" if countryname=="AUS"
replace countrycode = "BGD" if countryname=="BAN"
replace countrycode = "BLR" if countryname=="BEL"
replace countrycode = "BFA" if countryname=="BKF"
replace countrycode = "BEL" if countryname=="BLG"
replace countrycode = "BOL" if countryname=="BOL"
replace countrycode = "BIH" if countryname=="BOS"
replace countrycode = "BWA" if countryname=="BOT"
replace countrycode = "BRA" if countryname=="BRA"
replace countrycode = "BGR" if countryname=="BUL"
replace countrycode = "BDI" if countryname=="BUR"
replace countrycode = "CMR" if countryname=="CAM"
replace countrycode = "CAN" if countryname=="CAN"
replace countrycode = "CAF" if countryname=="CAR"
replace countrycode = "TCD" if countryname=="CHD"
replace countrycode = "CHL" if countryname=="CHL"
replace countrycode = "CHN" if countryname=="CHN"
replace countrycode = "KHM" if countryname=="CMB"
replace countrycode = "COL" if countryname=="COL"
replace countrycode = "COG" if countryname=="CON"
replace countrycode = "CRI" if countryname=="COS"
replace countrycode = "HRV" if countryname=="CRO"
replace countrycode = "CUB" if countryname=="CUB"
replace countrycode = "CZE" if countryname=="CZR"
replace countrycode = "DNK" if countryname=="DEN"
replace countrycode = "DOM" if countryname=="DOM"
replace countrycode = "ECU" if countryname=="ECU"
replace countrycode = "EGY" if countryname=="EGY"
replace countrycode = "SLV" if countryname=="ELS"
replace countrycode = "GNB" if countryname=="EQU"
replace countrycode = "EST" if countryname=="EST"
replace countrycode = "FIN" if countryname=="FIN"
replace countrycode = "FRA" if countryname=="FRA"
replace countrycode = "GAB" if countryname=="GAB"
replace countrycode = "GMB" if countryname=="GAM"
replace countrycode = "GER" if countryname=="GER"
replace countrycode = "GHA" if countryname=="GHA"
replace countrycode = "GRC" if countryname=="GRE"
replace countrycode = "GTM" if countryname=="GUA"
replace countrycode = "GIN" if countryname=="GUI"
replace countrycode = "HTI" if countryname=="HAI"
replace countrycode = "HKG" if countryname=="HNK"
replace countrycode = "HND" if countryname=="HON"
replace countrycode = "HUN" if countryname=="HUN"
replace countrycode = "IDN" if countryname=="IDS"
replace countrycode = "IND" if countryname=="IND"
replace countrycode = "IRL" if countryname=="IRE"
replace countrycode = "IRN" if countryname=="IRN"
replace countrycode = "IRQ" if countryname=="IRQ"
replace countrycode = "ISR" if countryname=="ISR"
replace countrycode = "ITA" if countryname=="ITA"
replace countrycode = "JPN" if countryname=="JAP"
replace countrycode = "JOR" if countryname=="JOR"
replace countrycode = "KAZ" if countryname=="KAZ"
replace countrycode = "KEN" if countryname=="KEN"
replace countrycode = "KOR" if countryname=="KRS"
replace countrycode = "KWT" if countryname=="KUW"
replace countrycode = "LAO" if countryname=="LAO"
replace countrycode = "LBY" if countryname=="LBY"
replace countrycode = "LBN" if countryname=="LEB"
replace countrycode = "LSO" if countryname=="LES"
replace countrycode = "LBR" if countryname=="LIB"
replace countrycode = "LTU" if countryname=="LTH"
replace countrycode = "LVA" if countryname=="LTV"
replace countrycode = "MKD" if countryname=="MAC"
replace countrycode = "MLI" if countryname=="MAL"
replace countrycode = "MUS" if countryname=="MAS"
replace countrycode = "MRT" if countryname=="MAU"
replace countrycode = "MEX" if countryname=="MEX"
replace countrycode = "MWI" if countryname=="MLW"
replace countrycode = "MYS" if countryname=="MLY"
replace countrycode = "MDA" if countryname=="MOL"
replace countrycode = "MNG" if countryname=="MON"
replace countrycode = "MAR" if countryname=="MOR"
replace countrycode = "MOZ" if countryname=="MOZ"
replace countrycode = "NPL" if countryname=="NEP"
replace countrycode = "NZL" if countryname=="NEW"
replace countrycode = "NGA" if countryname=="NGA"
replace countrycode = "NIC" if countryname=="NIC"
replace countrycode = "NER" if countryname=="NIG"
replace countrycode = "NOR" if countryname=="NOR"
replace countrycode = "NLD" if countryname=="NTH"
replace countrycode = "OMN" if countryname=="OMA"
replace countrycode = "PAN" if countryname=="PAN"
replace countrycode = "PER" if countryname=="PER"
replace countrycode = "PHL" if countryname=="PHI"
replace countrycode = "POL" if countryname=="POL"
replace countrycode = "PRT" if countryname=="POR"
replace countrycode = "PRY" if countryname=="PRG"
replace countrycode = "ROM" if countryname=="ROM"
replace countrycode = "RUS" if countryname=="RUS"
replace countrycode = "RWA" if countryname=="RWA"
replace countrycode = "ZAF" if countryname=="SAF"
replace countrycode = "SAU" if countryname=="SAU"
replace countrycode = "SGP" if countryname=="SNG"
replace countrycode = "SOM" if countryname=="SOM"
replace countrycode = "ESP" if countryname=="SPA"
replace countrycode = "LKA" if countryname=="SRI"
replace countrycode = "SLE" if countryname=="SRL"
replace countrycode = "SDN" if countryname=="SUD"
replace countrycode = "SVK" if countryname=="SVK"
replace countrycode = "SVN" if countryname=="SVN"
replace countrycode = "SWZ" if countryname=="SWA"
replace countrycode = "SWE" if countryname=="SWE"
replace countrycode = "CHE" if countryname=="SWZ"
replace countrycode = "SYR" if countryname=="SYR"
replace countrycode = "TWN" if countryname=="TAI"
replace countrycode = "TZA" if countryname=="TAN"
replace countrycode = "THA" if countryname=="THA"
replace countrycode = "TGO" if countryname=="TOG"
replace countrycode = "TUN" if countryname=="TUN"
replace countrycode = "TUR" if countryname=="TUR"
replace countrycode = "ARE" if countryname=="UAE"
replace countrycode = "UGA" if countryname=="UGA"
replace countrycode = "UKR" if countryname=="UKR"
replace countrycode = "GBR" if countryname=="UNK"
replace countrycode = "URY" if countryname=="URG"
replace countrycode = "USA" if countryname=="USA"
replace countrycode = "VEN" if countryname=="VNZ"
replace countrycode = "VNM" if countryname=="VTM"
replace countrycode = "YEM" if countryname=="YEM"
replace countrycode = "ZMB" if countryname=="ZAM"
replace countrycode = "ZWE" if countryname=="ZBW"

drop if countrycode==""

egen tech=group(technologyname)
egen cc=group(countrycode)

tsset  tech cc

xtreg lagsprecise, fe
predict lagsprecise_fe, u

xtreg intensive, fe
predict intensive_fe, u

collapse (mean) lagsprecise* intensive*, by(countrycode)

cd "`path0'Workfiles"
save CominMestieri_processed, replace
